feat: management API endpoints for functions (index / show / delete)#2137
Open
mm-zacharydavison wants to merge 1 commit intosequinstream:mainfrom
Open
feat: management API endpoints for functions (index / show / delete)#2137mm-zacharydavison wants to merge 1 commit intosequinstream:mainfrom
mm-zacharydavison wants to merge 1 commit intosequinstream:mainfrom
Conversation
4fa6f39 to
9fd88e2
Compare
Exposes index / show / delete for functions at /api/functions. Fills a gap that forced operators into either the LiveView UI or direct DB access to clean up orphaned transforms/enrichments — config apply is upsert-only and never removes them. - Extends Consumers.find_function/2 with :id_or_name lookup, matching how other resources accept either a UUID or a human name. - Controller mirrors HttpEndpointController conventions; JSON view reuses Sequin.Transforms.to_external/1. - Delete preserves the existing foreign-key guards on sink_consumers.function_id and sink_consumers.routing_id, so sinks still pin their functions. Create/update are deliberately out of scope — those remain owned by sequin config apply / the web UI, where validation is centralized. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9fd88e2 to
b765ce9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds REST management API endpoints for functions:
GET /api/functions— list all functions for the authenticated accountGET /api/functions/:id_or_name— fetch oneDELETE /api/functions/:id_or_name— delete oneWhy
Today
sequin config applyupserts functions but never removes them (see the comment atupsert_functions/2— omitting a function from YAML does not delete it). The only way to delete a function is the LiveView UI. That makes automated lifecycle management (e.g. cleaning up orphaned functions after rename/recolor deploys, or from orchestrator tools) impossible via the management API.This PR fills that gap with the read + delete half of the CRUD surface. Create/update are intentionally not included — they remain owned by
config applyand the LiveView UI, where validation and complex function-type handling already live. Opening that up later is a separate conversation; the read + delete endpoints are the minimum useful surface and composed cleanly on top of existingConsumersfunctions.Implementation notes
Consumers.find_function/2with:id_or_name, mirroring the existing lookup pattern for HTTP endpoints and sinks (Function.where_id_or_name/2already existed).HttpEndpointController/SinkConsumerControllerconventions. JSON view reusesSequin.Transforms.to_external/1.sink_consumers.function_idandsink_consumers.routing_id— a function still attached to a sink cannot be deleted.Tests
Controller tests cover:
Related context
Our team runs a red-black orchestrator on top of Sequin (sequin-red-black) that creates colored variants of functions (
<pipeline>_<color>-transform) per deploy. After activating a new color and dropping the old, the old functions become orphans that only the UI can delete. This endpoint is the primary piece we need for end-to-end cleanup automation.Happy to adjust scope / naming / placement per maintainer preference.